﻿#include "sky.h"

Sky::Sky()
{
    X = 0;
    Y = 0;
    Z = 0;
    radius = 0;
    R = 100;
}
void Sky::InitSky(float skyX,float skyY,float skyZ,float skyR,unsigned int texture)
{
    X = skyX;
    Y = skyY;
    Z = skyZ;
    R = skyR;
    T = texture;
    // 新对象
    qobj = gluNewQuadric();
    //对于面上的每一个点生成法向量，当然是因为光照的需要了，，，
    gluQuadricNormals(qobj,GLU_SMOOTH);
    //纹理打开纹理贴图
    gluQuadricTexture(qobj,GL_TRUE);
}
void Sky::ShowSky()
{
    radius += 0.08;
    //开启贴图
    glEnable(GL_TEXTURE_2D);
    glPushMatrix();
    //glFrontFace(GL_CCW);
    //去除后向面
    glCullFace(GL_BACK);
    // 绑定纹理，在init时已经设置了他生成纹理坐标，绑定即可
    glBindTexture(GL_TEXTURE_2D, T);
    glTranslatef(X,Y,Z);
    glRotatef(radius, 0.0f, 1.0f, 0.0f); //天空慢慢旋转,模拟云流动
    glRotatef(90,1,0,0);
    glColor4f(1,1,1,1);
    //画个大大大的qiu
    gluSphere(qobj,R,32,32);
    glPopMatrix();
    glDisable(GL_TEXTURE_2D);
}
float Sky::GetSkyR()
{
    return R;
}
float Sky::GetSkyX()
{
    return X;
}
float Sky::GetSkyY()
{
    return Y;
}
float Sky::GetSkyZ()
{
    return Z;
}
